/**********************************************************************
 * Project : WoWGuildRoster (http://www.codeplex.com/WowGuildRoster/)
 * Module  : DotNetWarcraft.WoWGuildRoster.Business.GuildRoster
 **********************************************************************
 * 
 * 
 * 
 **********************************************************************
 * License : All code is subject to licensing terms per the Microsoft
 *   Permissive License (Ms-PL) v1.1. For full license information,
 *   refer to the packaged license.txt file.
 **********************************************************************
 * Revision History:
 * -----------------
 * 2007-07-29 -- Cliff Simpkins: Initial Version
 * 2007-08-02 -- Cliff Simpkins: Added properties and constructors
 * 2007-09-02 -- Cliff Simpkins: Added guild rank properties
 * 2009-01-02 -- Cliff Simpkins: Added method to retrieve guild rank
 **********************************************************************
 */
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

using DotNetWarcraft.Common;

namespace DotNetWarcraft.WoWGuildRoster.Business {
  /// <summary>
  /// Roster entry that contains information about a Guild. This information is fairly generic,
  ///   and is supplemented by the characters connected to it.
  /// </summary>
  public class GuildRoster {

    #region Protected Members
    protected int _roster_id;

    protected String _guild_name;
    protected String _guild_server;
    protected int _guild_region;
    protected int _guild_alts_to;

    protected String _guildRank_0;
    protected String _guildRank_1;
    protected String _guildRank_2;
    protected String _guildRank_3;
    protected String _guildRank_4;
    protected String _guildRank_5;
    protected String _guildRank_6;
    protected String _guildRank_7;
    protected String _guildRank_8;
    protected String _guildRank_9;
    protected String _guildRank_10;

    protected String _guild_graphic;

    protected DateTime _last_load_date;
    protected int _last_load_id;

    protected DateTime _last_update_date;
    protected int _last_update_by;
    #endregion
		#region Public Properties
    public int Roster_ID {
      get	{ return _roster_id; }
      set	{ _roster_id = value; }
    }
		
    public String Guild_Name {
      get {
        return _guild_name;
      }
      set {
        _guild_name = value;
      }
    }
    public String Guild_Server {
      get {
        return _guild_server;
      }
      set {
        _guild_server = value;
      }
    }
    public int Guild_Alts_To {
      get {
        return _guild_alts_to;
      }
      set {
        _guild_alts_to = value;
      }
    }
    public String Guild_Graphic {
      get {
        return _guild_graphic;
      }
      set {
        _guild_graphic = value;
      }
    }

    public int Guild_Region {
      get {
        return _guild_region;
      }
      set {
        _guild_region = value;
      }
    }
    public WarcraftRegions Guild_Region_Enum {
      get {
        return WGRConstants.WowRegion_Enum(this.Guild_Region);
      }
      set {
        this.Guild_Region = WGRConstants.WowRegion_Int(value);
      }
    }

    public String GuildRank0 {
      get {
        return _guildRank_0;
      }
      set {
        _guildRank_0 = value;
      }
    }
    public String GuildRank1 {
      get {
        return _guildRank_1;
      }
      set {
        _guildRank_1 = value;
      }
    }
    public String GuildRank2 {
      get {
        return _guildRank_2;
      }
      set {
        _guildRank_2 = value;
      }
    }
    public String GuildRank3 {
      get {
        return _guildRank_3;
      }
      set {
        _guildRank_3 = value;
      }
    }
    public String GuildRank4 {
      get {
        return _guildRank_4;
      }
      set {
        _guildRank_4 = value;
      }
    }
    public String GuildRank5 {
      get {
        return _guildRank_5;
      }
      set {
        _guildRank_5 = value;
      }
    }
    public String GuildRank6 {
      get {
        return _guildRank_6;
      }
      set {
        _guildRank_6 = value;
      }
    }
    public String GuildRank7 {
      get {
        return _guildRank_7;
      }
      set {
        _guildRank_7 = value;
      }
    }
    public String GuildRank8 {
      get {
        return _guildRank_8;
      }
      set {
        _guildRank_8 = value;
      }
    }
    public String GuildRank9 {
      get {
        return _guildRank_9;
      }
      set {
        _guildRank_9 = value;
      }
    }
    public String GuildRank10 {
      get {
        return _guildRank_10;
      }
      set {
        _guildRank_10 = value;
      }
    }

    public DateTime Last_Load_Date {
      get	{ return _last_load_date; }
      set	{ _last_load_date = value; }
    }
    public int Last_Load_ID {
      get	{ return _last_load_id; }
      set	{ _last_load_id = value; }
    }

    public DateTime Last_Update_Date {
      get {
        return _last_update_date;
      }
      set {
        _last_update_date = value;
      }
    }
    public int Last_Update_By {
      get {
        return _last_update_by;
      }
      set {
        _last_update_by = value;
      }
    }
    #endregion

		#region Constructors
		public GuildRoster() : base() {
      //Basic Variable Initialization
      this.Roster_ID = -1;
      this.Guild_Name = "";
      this.Guild_Server = "";
      this.Guild_Alts_To = -1;
      this.Guild_Graphic = "";
      this.Guild_Region_Enum = WarcraftRegions.RegionUnknown;

      this.GuildRank0 = "";
      this.GuildRank1 = "";
      this.GuildRank2 = "";
      this.GuildRank3 = "";
      this.GuildRank4 = "";
      this.GuildRank5 = "";
      this.GuildRank6 = "";
      this.GuildRank7 = "";
      this.GuildRank8 = "";
      this.GuildRank9 = "";
      this.GuildRank10 = "";

      this.Last_Load_Date = DateTime.MinValue;
      this.Last_Load_ID = -1;

      this.Last_Update_Date = DateTime.UtcNow;
      this.Last_Update_By = -1;
    }
    public GuildRoster(int rosterID) : base() {
      this.Roster_ID = rosterID;
		}
    public GuildRoster(DataRow rosterSrc) : base() {
      if (rosterSrc == null) {
        throw new DotNetWarcraft.WoWGuildRoster.Business.Exceptions.RosterRowInvalid(this.Roster_ID);
        }
      this.Roster_ID = SqlDataUtils.RetrieveDbInt(rosterSrc["roster_id"]);
      this.Guild_Name = SqlDataUtils.RetrieveDbString(rosterSrc["guild_name"]);
      this.Guild_Server = SqlDataUtils.RetrieveDbString(rosterSrc["guild_server"]);
      this.Guild_Region = SqlDataUtils.RetrieveDbInt(rosterSrc["guild_region"]);

      this.Guild_Alts_To = SqlDataUtils.RetrieveDbInt(rosterSrc["guild_alts_to"]);
      this.Guild_Graphic = SqlDataUtils.RetrieveDbString(rosterSrc["guild_graphic"]);

      this.GuildRank0 = SqlDataUtils.RetrieveDbString(rosterSrc["guild_rank0"]);
      this.GuildRank1 = SqlDataUtils.RetrieveDbString(rosterSrc["guild_rank1"]);
      this.GuildRank2 = SqlDataUtils.RetrieveDbString(rosterSrc["guild_rank2"]);
      this.GuildRank3 = SqlDataUtils.RetrieveDbString(rosterSrc["guild_rank3"]);
      this.GuildRank4 = SqlDataUtils.RetrieveDbString(rosterSrc["guild_rank4"]);
      this.GuildRank5 = SqlDataUtils.RetrieveDbString(rosterSrc["guild_rank5"]);
      this.GuildRank6 = SqlDataUtils.RetrieveDbString(rosterSrc["guild_rank6"]);
      this.GuildRank7 = SqlDataUtils.RetrieveDbString(rosterSrc["guild_rank7"]);
      this.GuildRank8 = SqlDataUtils.RetrieveDbString(rosterSrc["guild_rank8"]);
      this.GuildRank9 = SqlDataUtils.RetrieveDbString(rosterSrc["guild_rank9"]);
      this.GuildRank10 = SqlDataUtils.RetrieveDbString(rosterSrc["guild_rank10"]);

      this.Last_Load_Date = SqlDataUtils.RetrieveDbDate(rosterSrc["last_load_date"]);
      this.Last_Load_ID = SqlDataUtils.RetrieveDbInt(rosterSrc["last_load_id"]);

      this.Last_Update_Date = SqlDataUtils.RetrieveDbDate(rosterSrc["last_update_date"]);
      this.Last_Update_By = SqlDataUtils.RetrieveDbInt(rosterSrc["last_update_by"]);
    }
    #endregion

    #region Public Methods
    public String GetGuildRank(int guildRank) {

      switch (guildRank) {
        case 0:
          return this.GuildRank0;
        case 1:
          return this.GuildRank1;
        case 2:
          return this.GuildRank2;
        case 3:
          return this.GuildRank3;
        case 4:
          return this.GuildRank4;
        case 5:
          return this.GuildRank5;
        case 6:
          return this.GuildRank6;
        case 7:
          return this.GuildRank7;
        case 8:
          return this.GuildRank8;
        case 9:
          return this.GuildRank9;
        case 10:
          return this.GuildRank10;
        default:
          return "Unknown Rank";
        }

      }
    #endregion
    }
}
